#coding=utf-8
import scrapy
from T_spider.items import TSpiderItem

class Demo_spider(scrapy.Spider):
    name = "demo"
    allowed_domains = ["czlgj.com"]
    
    def start_requests(self):
        urls = [
                "http://www.czlgj.com",
        ]
        for url in urls:
            yield scrapy.Request(url=url,callback=self.parse)

    def parse(self,response):
        for each in response.xpath("//ul//li"):
            item = TSpiderItem()
            item['title'] = each.xpath("a/@title").extract()
            item['link'] = each.xpath("a/@href").extract()
            item['date'] = each.xpath("span/text()").extract()
            image_url = each.xpath("//a/img/@src").extract()
            print(image_url)
            result = []
            for i in image_url:
                 result.append("https://www.czlgj.com/"+i)
            item['image_urls'] = result
            yield item
